<Page x:Class="VRacer.Pages.MultiplayerPreferences"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:common="clr-namespace:VRacer;assembly=VRacer"
    xmlns:local="clr-namespace:VRacer"
      xmlns:wpf="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
      xmlns:controls="clr-namespace:VRacer.Controls"
      xmlns:converters="clr-namespace:VRacer.Client.Converters"
    Title="MultiplayerPreferences" DataContext="{Binding Game, Source={x:Static local:Business.Instance}}">

    <Page.Resources>
        <controls:PlayersListTemplateSelector x:Key="playersListDataTemplateSelector"/>

        <converters:PlayerTypeConverter x:Key="PlayerTypeConverter" />

    </Page.Resources>

    <Border Style="{StaticResource PropertiesBorder}">
        

        <StackPanel>
            <Label FontWeight="Bold">Select track:</Label>
            <Border Margin="10">
                <ComboBox MinHeight="80" ItemsSource="{Binding Tracks}" SelectedValue="{Binding CurrentTrack}" />
            </Border>

            <Label FontWeight="Bold">Players:</Label>
            <Border Name="_gameDetails" Margin="10">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <wpf:DataGrid Background="Transparent" VerticalScrollBarVisibility="Auto" MinHeight="400" CanUserAddRows="False" AutoGenerateColumns="False" AlternatingRowBackground="#dddddd" GridLinesVisibility="Vertical" Grid.Row="1" RowDetailsTemplateSelector="{StaticResource playersListDataTemplateSelector}" ItemsSource="{Binding Game.Players, Source={x:Static local:Business.Instance}}" RowDetailsVisibilityMode="VisibleWhenSelected">

                        <wpf:DataGrid.CellStyle>
                            <Style TargetType="{x:Type wpf:DataGridCell}">
                                <Setter Property="Margin" Value="5" />
                            </Style>
                        </wpf:DataGrid.CellStyle>

                        <wpf:DataGrid.RowStyle>
                            <Style TargetType="{x:Type wpf:DataGridRow}">
                            </Style>
                        </wpf:DataGrid.RowStyle>

                        <wpf:DataGrid.Resources>
                            <DataTemplate x:Key="AIPlayerDetailsTemplate">
                            </DataTemplate>

                            <DataTemplate x:Key="HumanPlayerDetailsTemplate">
                            </DataTemplate>
                        </wpf:DataGrid.Resources>

                        <wpf:DataGrid.Columns>
                            <wpf:DataGridTemplateColumn Width="30" Header="C" CanUserSort="False" CanUserResize="False" IsReadOnly="True">
                                <wpf:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Border>
                                            <Rectangle Fill="{Binding BrushColor}" />
                                        </Border>
                                    </DataTemplate>
                                </wpf:DataGridTemplateColumn.CellTemplate>
                            </wpf:DataGridTemplateColumn>
                            <wpf:DataGridTextColumn Width="200" Binding="{Binding Title}" Header="Title" />
                            <wpf:DataGridTextColumn IsReadOnly="True" Binding="{Binding Converter={StaticResource PlayerTypeConverter}}" Header="Type" />
                            <wpf:DataGridTemplateColumn Width="100" Header="" CanUserSort="False" CanUserResize="False" IsReadOnly="True">
                                <wpf:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Click="Button_Click_RemoveSelectedPlayer" Tag="{Binding}">Remove</Button>
                                    </DataTemplate>
                                </wpf:DataGridTemplateColumn.CellTemplate>
                            </wpf:DataGridTemplateColumn>
                        </wpf:DataGrid.Columns>
                    </wpf:DataGrid>
                    <!--
                        <ListView ItemsSource="{Binding Game.Players}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Width="140" Header="Title" DisplayMemberBinding="{Binding Title}" />
                                    <GridViewColumn Width="140" Header="Color" />
                                    <GridViewColumn Width="140" Header="Type" DisplayMemberBinding="{Binding}" />
                                </GridView>
                            </ListView.View>
                        </ListView>-->
                </Grid>
            </Border>
        </StackPanel>
    </Border>

</Page>
